import time
import math
from car_move import move_to, move_by, turn_to, move_by2
from car_op import Serial_init
from car_visual import see_light,see_bike
from speaker import talk_hood2, talk_hood1, talk_fire1, talk_trash, talk_fire3, talk_num2, talk_num1, \
    talk_num3, talk_fire2, talk_bike, talk_end




def main():
    Serial_init()

    # 前往红绿灯1等待点
    move_to(1.2,0.3)
    while see_light()!='G':
        time.sleep(0.1)

    #前往转向点1
    move_to(3.7,0.3)

    #前往转向点2
    move_to(3.7,1.5)

    #平移至B街区
    move_by('a',2.9,1.5)
    talk_hood2()

    #旋转至A街区
    turn_to(math.pi/2)
    talk_hood1()

    #旋转并平移至转向点3
    move_to(2.1,1.5)

    #平移至建筑1监测点
    move_by('d',2.1,2.1)
    talk_fire1()

    #朝向红绿灯2
    turn_to(-math.pi/2)
    while see_light()!='G':
        time.sleep(0.1)
    #前往垃圾桶检测点
    move_to(2.1,3)
    turn_to(0)
    talk_trash()

    #转向建筑3观测点
    turn_to(math.pi)
    talk_fire3()

    #平移至转向点4
    move_by('d',2.1,3.7)

    #平移至车牌1观测点
    move_to(0.9,3.7)
    talk_num1()

    # 平移至车牌2观测点
    move_by('a',0.9,3.1)
    talk_num2()

    # 平移至车牌3观测点
    move_by('a',0.9,2.5)
    talk_num3()

    #旋转至建筑2观测点
    turn_to(0)
    talk_fire2()
    #旋转朝向电动车一侧
    turn_to(math.pi)

    # 缓慢！平移扫描电动车停车区
    move_by('a', 0.9,2.2)
    see_bike()
    move_by2('a',0.9,0.3,20)
    talk_bike()

    #进库
    move_to(0.3,0.3)

    #转向
    turn_to(0)
    talk_end()





if __name__ == "__main__":
    #main()
    move_to(1.2, 0.3)